package com.more.spring.boot.springbootredisdemo.deepseek.service;

import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class DeepSeekClient {

    private final RestTemplate restTemplate;

    private final HttpHeaders headers;

    public DeepSeekClient(RestTemplate restTemplate, HttpHeaders headers) {
        this.restTemplate = restTemplate;
        this.headers = headers;
    }


    public String callDeepSeekApi(String promt) {
        String baseUrl = "https://api.deepseek.com/v1/chat/completions";
        HttpEntity<String> request = new HttpEntity<>(promt, headers);
        ResponseEntity<String> response = restTemplate.exchange(baseUrl, HttpMethod.POST, request, String.class);
        return response.getBody();
    }
}
